home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gdevcgml.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  13.8 KB  |  385 lines

  1. /* Copyright (C) 1995, 1996 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gdevcgml.h,v 1.2 2000/09/19 19:00:11 lpd Exp $ */
  20. /* Interface definitions for CGM-writing library */
  21.  
  22. #ifndef gdevcgml_INCLUDED
  23. #  define gdevcgml_INCLUDED
  24.  
  25. /* The names in the following follow the CGM standard exactly, */
  26. /* except that we have substituted the American spellings of */
  27. /* color (colour) and center (centre). */
  28.  
  29. /* ================ Types ================ */
  30.  
  31. /* Define the abstract type for the CGM writer state. */
  32. typedef struct cgm_state_s cgm_state;
  33.  
  34. /* Define the type for the allocator used by the CGM writer. */
  35. typedef struct cgm_allocator_s {
  36.     void *private_data;
  37.     void *(*alloc) (P2(void *, uint));
  38.     void (*free) (P2(void *, void *));
  39. } cgm_allocator;
  40.  
  41. /* Define types for CGM coordinates. */
  42. typedef int cgm_int;
  43. typedef double cgm_real;
  44. typedef union cgm_vdc_s {
  45.     cgm_int integer;
  46.     cgm_real real;
  47. } cgm_vdc;
  48. typedef struct cgm_int_point_s {
  49.     cgm_int x, y;
  50. } cgm_int_point;
  51. typedef struct cgm_real_point_s {
  52.     cgm_real x, y;
  53. } cgm_real_point;
  54. typedef union cgm_point_s {
  55.     cgm_int_point integer;
  56.     cgm_real_point real;
  57. } cgm_point;
  58.  
  59. /* Define types for colors. */
  60. typedef struct cgm_rgb_s {
  61.     cgm_int r, g, b;
  62. } cgm_rgb;
  63. typedef union cgm_color_s {
  64.     cgm_int index;
  65.     cgm_rgb rgb;
  66. } cgm_color;
  67.  
  68. /*
  69.  * Define other types used in CGM elements or API calls.
  70.  * If cgm_xxx is an enumerated type, let xxx' be xxx with any of the
  71.  * following words dropped: mode, specification, type; then the values
  72.  * of the enumerated type are named cgm_xxx'_yyy.
  73.  */
  74. typedef enum {
  75.     cgm_vdc_integer = 0,
  76.     cgm_vdc_real
  77. } cgm_vdc_type;
  78. typedef struct cgm_string_s {
  79.     const char *chars;
  80.     uint length;
  81. } cgm_string;
  82. typedef enum {
  83.     cgm_scaling_abstract = 0,
  84.     cgm_scaling_metric
  85. } cgm_scaling_mode;
  86. typedef enum {
  87.     cgm_color_selection_indexed = 0,
  88.     cgm_color_selection_direct
  89. } cgm_color_selection_mode;
  90. typedef enum {
  91.     cgm_line_marker_absolute = 0,
  92.     cgm_line_marker_scaled
  93. } cgm_line_marker_specification_mode;
  94. typedef cgm_line_marker_specification_mode
  95.         cgm_line_width_specification_mode, cgm_marker_size_specification_mode,
  96.         cgm_edge_width_specification_mode;
  97. typedef union cgm_line_marker_extent_s {
  98.     cgm_vdc absolute;
  99.     cgm_real scaled;
  100. } cgm_line_marker_extent;
  101. typedef cgm_line_marker_extent
  102.         cgm_line_width, cgm_marker_size, cgm_edge_width;
  103. typedef enum {
  104.     cgm_transparency_off = 0,
  105.     cgm_transparency_on
  106. } cgm_transparency;
  107. typedef enum {
  108.     cgm_clip_off = 0,
  109.     cgm_clip_on
  110. } cgm_clip_indicator;
  111. typedef struct cgm_precision_s {
  112.     enum {
  113.     cgm_representation_floating, cgm_representation_fixed
  114.     } representation;
  115.     int exponent_or_whole_width;
  116.     int fraction_width;
  117. } cgm_precision;
  118. typedef enum {
  119.     cgm_line_solid = 1,
  120.     cgm_line_dash,
  121.     cgm_line_dot,
  122.     cgm_line_dash_dot,
  123.     cgm_line_dash_dot_dot
  124. } cgm_line_type;
  125. typedef enum {
  126.     cgm_marker_dot = 1,
  127.     cgm_marker_plus,
  128.     cgm_marker_asterisk,
  129.     cgm_marker_circle,
  130.     cgm_marker_cross
  131. } cgm_marker_type;
  132. typedef enum {
  133.     cgm_text_precision_string = 0,
  134.     cgm_text_precision_character,
  135.     cgm_text_precision_stroke
  136. } cgm_text_precision;
  137. typedef enum {
  138.     cgm_text_path_right = 0,
  139.     cgm_text_path_left,
  140.     cgm_text_path_up,
  141.     cgm_text_path_down
  142. } cgm_text_path;
  143. typedef enum {
  144.     cgm_text_horizontal_normal = 0,
  145.     cgm_text_horizontal_left,
  146.     cgm_text_horizontal_center,
  147.     cgm_text_horizontal_right,
  148.     cgm_text_horizontal_continuous
  149. } cgm_text_alignment_horizontal;
  150. typedef enum {
  151.     cgm_text_vertical_normal = 0,
  152.     cgm_text_vertical_top,
  153.     cgm_text_vertical_cap,
  154.     cgm_text_vertical_half,
  155.     cgm_text_vertical_base,
  156.     cgm_text_vertical_bottom,
  157.     cgm_text_vertical_continuous
  158. } cgm_text_alignment_vertical;
  159. typedef enum {
  160.     cgm_interior_style_hollow = 0,
  161.     cgm_interior_style_solid,
  162.     cgm_interior_style_pattern,
  163.     cgm_interior_style_hatch,
  164.     cgm_interior_style_empty
  165. } cgm_interior_style;
  166. typedef enum {
  167.     cgm_hatch_horizontal = 1,
  168.     cgm_hatch_vertical,
  169.     cgm_hatch_positive_slope,
  170.     cgm_hatch_negative_slope,
  171.     cgm_hatch_combined_v_h_slant,
  172.     cgm_hatch_combined_l_r_slant
  173. } cgm_hatch_index;
  174. typedef enum {
  175.     cgm_arc_closure_pie = 0,
  176.     cgm_arc_closure_chord
  177. } cgm_arc_closure;
  178. typedef enum {
  179.     cgm_edge_out_invisible = 0,
  180.     cgm_edge_out_visible,
  181.     cgm_edge_out_close_invisible,
  182.     cgm_edge_out_close_visible
  183. } cgm_edge_out;
  184. typedef struct cgm_polygon_edge_s {
  185.     cgm_point vertex;
  186.     cgm_edge_out edge_out;
  187. } cgm_polygon_edge;
  188. typedef enum {
  189.     cgm_cell_mode_run_length = 0,
  190.     cgm_cell_mode_packed
  191. } cgm_cell_representation_mode;
  192. typedef enum {
  193.     cgm_edge_solid = 1,
  194.     cgm_edge_dash,
  195.     cgm_edge_dot,
  196.     cgm_edge_dash_dot,
  197.     cgm_edge_dash_dot_dot
  198. } cgm_edge_type;
  199. typedef enum {
  200.     cgm_aspect_source_individual = 0,
  201.     cgm_aspect_source_bundled
  202. } cgm_aspect_source;
  203. typedef enum {
  204.     cgm_aspect_line_type = 0,
  205.     cgm_aspect_line_width,
  206.     cgm_aspect_line_color,
  207.     cgm_aspect_marker_type,
  208.     cgm_aspect_marker_size,
  209.     cgm_aspect_marker_color,
  210.     cgm_aspect_text_font_index,
  211.     cgm_aspect_text_precision,
  212.     cgm_aspect_character_expansion_factor,
  213.     cgm_aspect_character_spacing,
  214.     cgm_aspect_text_color,
  215.     cgm_aspect_interior_style,
  216.     cgm_aspect_fill_color,
  217.     cgm_aspect_hatch_index,
  218.     cgm_aspect_pattern_index,
  219.     cgm_aspect_edge_type,
  220.     cgm_aspect_edge_width,
  221.     cgm_aspect_edge_color
  222. } cgm_aspect_type;
  223. typedef struct cgm_aspect_source_flag_s {
  224.     cgm_aspect_type type;
  225.     cgm_aspect_source source;
  226. } cgm_aspect_source_flag;
  227.  
  228. /* ================ API ================ */
  229.  
  230. typedef enum {
  231.     cgm_result_ok = 0,
  232.     cgm_result_wrong_state = -1,
  233.     cgm_result_out_of_range = -2,
  234.     cgm_result_io_error = -3,
  235.     cgm_result_out_of_memory = -4
  236. } cgm_result;
  237.  
  238. /* ---------------- Initialize/terminate ---------------- */
  239.  
  240. cgm_state *cgm_initialize(P2(FILE *, const cgm_allocator *));
  241. cgm_result cgm_terminate(P1(cgm_state *));
  242.  
  243. /* ---------------- Metafile elements ---------------- */
  244.  
  245. typedef struct cgm_metafile_elements_s {
  246.     cgm_int metafile_version;
  247.     cgm_string metafile_description;
  248.     cgm_vdc_type vdc_type;
  249.     int integer_precision;
  250.     cgm_precision real_precision;
  251.     int index_precision;
  252.     int color_precision;
  253.     int color_index_precision;
  254.     cgm_int maximum_color_index;
  255.     cgm_color color_value_extent[2];
  256.     const int *metafile_element_list;
  257.     int metafile_element_list_count;
  258.     const cgm_string *font_list;
  259.     int font_list_count;
  260.     /* character_set_list */
  261.     /* character_coding_announcer */
  262. } cgm_metafile_elements;
  263.  
  264. #define cgm_set_METAFILE_VERSION    (1L<<0)
  265. #define cgm_set_METAFILE_DESCRIPTION    (1L<<1)
  266. #define cgm_set_VDC_TYPE        (1L<<2)
  267. #define cgm_set_INTEGER_PRECISION    (1L<<3)
  268. #define cgm_set_REAL_PRECISION        (1L<<4)
  269. #define cgm_set_INDEX_PRECISION        (1L<<5)
  270. #define cgm_set_COLOR_PRECISION        (1L<<6)
  271. #define cgm_set_COLOR_INDEX_PRECISION    (1L<<7)
  272. #define cgm_set_MAXIMUM_COLOR_INDEX    (1L<<8)
  273. #define cgm_set_COLOR_VALUE_EXTENT    (1L<<9)
  274. #define cgm_set_METAFILE_ELEMENT_LIST    (1L<<10)
  275. #define cgm_set_FONT_LIST        (1L<<11)
  276. #define cgm_set_CHARACTER_SET_LIST    (1L<<12)
  277. #define cgm_set_CHARACTER_CODING_ANNOUNCER    (1L<<13)
  278.  
  279. cgm_result
  280. cgm_BEGIN_METAFILE(P3(cgm_state *, const char *, uint)), cgm_set_metafile_elements(P3(cgm_state *,
  281.                       const cgm_metafile_elements *, long)),
  282.      cgm_END_METAFILE(P1(cgm_state *));
  283.  
  284. /* ---------------- Picture elements ---------------- */
  285.  
  286. typedef struct cgm_picture_elements_s {
  287.     cgm_scaling_mode scaling_mode;
  288.     cgm_real scale_factor;
  289.     cgm_color_selection_mode color_selection_mode;
  290.     cgm_line_width_specification_mode line_width_specification_mode;
  291.     cgm_marker_size_specification_mode marker_size_specification_mode;
  292.     cgm_edge_width_specification_mode edge_width_specification_mode;
  293.     cgm_point vdc_extent[2];
  294.     cgm_color background_color;
  295. } cgm_picture_elements;
  296.  
  297. #define cgm_set_SCALING_MODE        (1L<<0)
  298. #define cgm_set_COLOR_SELECTION_MODE    (1L<<1)
  299. #define cgm_set_LINE_WIDTH_SPECIFICATION_MODE    (1L<<2)
  300. #define cgm_set_MARKER_SIZE_SPECIFICATION_MODE    (1L<<3)
  301. #define cgm_set_EDGE_WIDTH_SPECIFICATION_MODE    (1L<<4)
  302. #define cgm_set_VDC_EXTENT        (1L<<5)
  303. #define cgm_set_BACKGROUND_COLOR    (1L<<6)
  304.  
  305. cgm_result
  306. cgm_BEGIN_PICTURE(P3(cgm_state *, const char *, uint)), cgm_set_picture_elements(P3(cgm_state *,
  307.                        const cgm_picture_elements *, long)),
  308.      cgm_BEGIN_PICTURE_BODY(P1(cgm_state *)), cgm_END_PICTURE(P1(cgm_state *));
  309.  
  310. /* ---------------- Control elements ---------------- */
  311.  
  312. cgm_result
  313. cgm_VDC_INTEGER_PRECISION(P2(cgm_state *, int)), cgm_VDC_REAL_PRECISION(P2(cgm_state *, const cgm_precision *)),
  314.       cgm_AUXILIARY_COLOR(P2(cgm_state *, const cgm_color *)), cgm_TRANSPARENCY(P2(cgm_state *, cgm_transparency)),
  315.       cgm_CLIP_RECTANGLE(P2(cgm_state *, const cgm_point[2])), cgm_CLIP_INDICATOR(P2(cgm_state *, cgm_clip_indicator));
  316.  
  317. /* ---------------- Graphical primitive elements ---------------- */
  318.  
  319. cgm_result
  320. cgm_POLYLINE(P3(cgm_state *, const cgm_point *, int)), cgm_DISJOINT_POLYLINE(P3(cgm_state *, const cgm_point *, int)),
  321.     cgm_POLYMARKER(P3(cgm_state *, const cgm_point *, int)), cgm_TEXT(P5(cgm_state *, const cgm_point *, bool, const char *, uint)),
  322.      cgm_RESTRICTED_TEXT(P7(cgm_state *, const cgm_vdc *, const cgm_vdc *,
  323.                 const cgm_point *, bool, const char *, uint)),
  324.      cgm_APPEND_TEXT(P4(cgm_state *, bool, const char *, uint)), cgm_POLYGON(P3(cgm_state *, const cgm_point *, int)),
  325.     cgm_POLYGON_SET(P3(cgm_state *, const cgm_polygon_edge *, int)), cgm_CELL_ARRAY(P9(cgm_state *, const cgm_point * /*[3] */ , cgm_int,
  326.                  cgm_int, cgm_int, cgm_cell_representation_mode,
  327.                          const byte *, uint, uint)),
  328.       cgm_RECTANGLE(P3(cgm_state *, const cgm_point *, const cgm_point *)),
  329.       cgm_CIRCLE(P3(cgm_state *, const cgm_point *, const cgm_vdc *)),
  330.       cgm_CIRCULAR_ARC_3_POINT(P4(cgm_state *, const cgm_point *,
  331.                   const cgm_point *, const cgm_point *)),
  332.       cgm_CIRCULAR_ARC_3_POINT_CLOSE(P5(cgm_state *, const cgm_point *,
  333.                     const cgm_point *,
  334.                     const cgm_point *, cgm_arc_closure)),
  335.       cgm_CIRCULAR_ARC_CENTER(P7(cgm_state *, const cgm_point *,
  336.                  const cgm_vdc *, const cgm_vdc *,
  337.                  const cgm_vdc *, const cgm_vdc *,
  338.                  const cgm_vdc *)), cgm_CIRCULAR_ARC_CENTER_CLOSE(P8(cgm_state *, const cgm_point *,
  339.                        const cgm_vdc *, const cgm_vdc *,
  340.                        const cgm_vdc *, const cgm_vdc *,
  341.                      const cgm_vdc *, cgm_arc_closure)),
  342.       cgm_ELLIPSE(P4(cgm_state *, const cgm_point *, const cgm_point *,
  343.   const cgm_point *)), cgm_ELLIPTICAL_ARC(P8(cgm_state *, const cgm_point *,
  344.                        const cgm_point *, const cgm_point *,
  345.                        const cgm_vdc *, const cgm_vdc *,
  346.                      const cgm_vdc *, const cgm_vdc *)),
  347.       cgm_ELLIPTICAL_ARC_CLOSE(P9(cgm_state *, const cgm_point *,
  348.                   const cgm_point *, const cgm_point *,
  349.                   const cgm_vdc *, const cgm_vdc *,
  350.                   const cgm_vdc *, const cgm_vdc *,
  351.                   cgm_arc_closure));
  352.  
  353. /* ---------------- Attribute elements ---------------- */
  354.  
  355. cgm_result
  356. cgm_LINE_BUNDLE_INDEX(P2(cgm_state *, cgm_int)),
  357. cgm_LINE_TYPE(P2(cgm_state *, cgm_line_type)),
  358. cgm_LINE_WIDTH(P2(cgm_state *, const cgm_line_width *)), cgm_LINE_COLOR(P2(cgm_state *, const cgm_color *)),
  359.       cgm_MARKER_BUNDLE_INDEX(P2(cgm_state *, cgm_int)), cgm_MARKER_TYPE(P2(cgm_state *, cgm_marker_type)),
  360.       cgm_MARKER_SIZE(P2(cgm_state *, const cgm_marker_size *)), cgm_MARKER_COLOR(P2(cgm_state *, const cgm_color *)),
  361.       cgm_TEXT_BUNDLE_INDEX(P2(cgm_state *, cgm_int)), cgm_TEXT_FONT_INDEX(P2(cgm_state *, cgm_int)),
  362.       cgm_TEXT_PRECISION(P2(cgm_state *, cgm_text_precision)), cgm_CHARACTER_EXPANSION_FACTOR(P2(cgm_state *, cgm_real)),
  363.       cgm_CHARACTER_SPACING(P2(cgm_state *, cgm_real)), cgm_TEXT_COLOR(P2(cgm_state *, const cgm_color *)),
  364.       cgm_CHARACTER_HEIGHT(P2(cgm_state *, const cgm_vdc *)), cgm_CHARACTER_ORIENTATION(P5(cgm_state *, const cgm_vdc *,
  365.                        const cgm_vdc *, const cgm_vdc *,
  366.                               const cgm_vdc *)),
  367.       cgm_TEXT_PATH(P2(cgm_state *, cgm_text_path)), cgm_TEXT_ALIGNMENT(P5(cgm_state *, cgm_text_alignment_horizontal,
  368.                         cgm_text_alignment_vertical,
  369.                                cgm_real, cgm_real)),
  370.       cgm_CHARACTER_SET_INDEX(P2(cgm_state *, cgm_int)),    /* The following should be cgm_ALTERNATE_..., but the VAX DEC C */
  371.   /* compiler gives an error for names longer than 31 characters. */
  372.       cgm_ALT_CHARACTER_SET_INDEX(P2(cgm_state *, cgm_int)), cgm_FILL_BUNDLE_INDEX(P2(cgm_state *, cgm_int)),
  373.       cgm_INTERIOR_STYLE(P2(cgm_state *, cgm_interior_style)), cgm_FILL_COLOR(P2(cgm_state *, const cgm_color *)),
  374.       cgm_HATCH_INDEX(P2(cgm_state *, cgm_hatch_index)), cgm_PATTERN_INDEX(P2(cgm_state *, cgm_int)),
  375.       cgm_EDGE_BUNDLE_INDEX(P2(cgm_state *, cgm_int)), cgm_EDGE_TYPE(P2(cgm_state *, cgm_edge_type)),
  376.       cgm_EDGE_WIDTH(P2(cgm_state *, const cgm_edge_width *)), cgm_EDGE_COLOR(P2(cgm_state *, const cgm_color *)),
  377.       cgm_EDGE_VISIBILITY(P2(cgm_state *, bool)), cgm_FILL_REFERENCE_POINT(P2(cgm_state *, const cgm_point *)),
  378. /* PATTERN_TABLE */
  379.       cgm_PATTERN_SIZE(P5(cgm_state *, const cgm_vdc *, const cgm_vdc *,
  380.               const cgm_vdc *, const cgm_vdc *)), cgm_COLOR_TABLE(P4(cgm_state *, cgm_int, const cgm_color *, int)),
  381.     cgm_ASPECT_SOURCE_FLAGS(P3(cgm_state *,
  382.                    const cgm_aspect_source_flag *, int));
  383.  
  384. #endif /* gdevcgml_INCLUDED */
  385.